package com.atguigu.ssyx.acl.service.impl;

import com.atguigu.ssyx.acl.mapper.AdminMapper;
import com.atguigu.ssyx.acl.service.AdminService;
import com.atguigu.ssyx.model.acl.Admin;
import com.atguigu.ssyx.model.acl.Role;
import com.atguigu.ssyx.vo.acl.AdminQueryVo;
import com.atguigu.ssyx.vo.acl.RoleQueryVo;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.io.Serializable;


@Service
public class AdminServiceImpl  extends ServiceImpl<AdminMapper, Admin> implements AdminService {



    //角色分页列表
    @Override
    public IPage<Admin> selectPageUser(Page<Admin> pageParam, AdminQueryVo adminQueryVo) {

            //获取条件值：角色名称
            String userName = adminQueryVo.getUsername();
            String name= adminQueryVo.getName();
            //创建条件构造器对象
            LambdaQueryWrapper<Admin> wrapper = new LambdaQueryWrapper<>();
            //判断条件值是否为空
            if(!StringUtils.isEmpty(userName)) {
                //封装条件
                wrapper.eq(Admin::getUsername,userName);
            }

            if(!StringUtils.isEmpty(name)) {
            //封装条件
            wrapper.like(Admin::getName,name);
            }
            //调用mapper方法实现条件分页查询
            IPage<Admin> pageModel = baseMapper.selectPage(pageParam, wrapper);
            return pageModel;

    }
}
